/***************************************************************************
   Filename:    MainMenu.h
   Author:      Josh Partridge
   Description: Contains the MainMenu class, basically for switching states
****************************************************************************/

#ifndef MAINMENU_H_INCLUDED
#define MAINMENU_H_INCLUDED

#include "Brush.h"
#include "boxgen.h"
#include "StateMachine.h"
#include <string>

using namespace std;

class MainMenu
{
    private:
        //private state machine for tracking which option is selected
        State menuState;
        /*
        whether we are returning from an IN_GAME state
        determines whether we should provide a CONTINUE option
        */
        bool paused;
        //when the user hits the Enter key, we choose the current option
        bool chosen;

        /************************************************************************************
         Name:               cycleState
         Description:        increment or decrement the current option
         Input:
                        key: The key the user has pressed ("up", "down", or "esc") (string)
        *************************************************************************************/
        void cycleState(string key);

        /************************************************************************************
         Name:               handleInput
         Description:        calls cycleState or sets choosen to true when appropriate
         Input:
                         ch: The key the user has pressed ( provided by getInput() in helpers)
        *************************************************************************************/
        void handleInput(char ch);

        /************************************************************************************
         Name:               dispOptions
         Description:        prints the options and highlights the current choice
         Input:
                      brush: reference to main's brush object
        *************************************************************************************/
        void dispOptions(Brush& brush);

    public:

        /************************************************************************************
         Name:               MainMenu - default constructor
         Description:        initializes paused and MainMenu's State
        *************************************************************************************/
        MainMenu();

        /************************************************************************************
         Name:               run
         Description:        contains the loop that keeps us in the main menu
         Input:
               stateMachine: reference to main's StateMachine
        *************************************************************************************/
        void run(StateMachine& stateMachine, Brush& brush);

        /************************************************************************************
         Name:               unlockContine
         Description:        sets paused to true (so CONTINUE option is available)
        *************************************************************************************/
        void unlockContinue();

        /************************************************************************************
         Name:               lockContinue
         Description:        sets paused to false (so CONTINUE option is unavailable)
        *************************************************************************************/
        void lockContinue();
};

#endif // MAINMENU_H_INCLUDED
